//
//  APLoginView.m
//  AqualPolo
//
//  Created by dong on 2024/5/1.
//

#import "APLoginView.h"

@interface APLoginView ()

@end

@implementation APLoginView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        _scrollView = [[UIScrollView alloc] init];
//        [self addSubview:_scrollView];
//        [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.edges.equalTo(self);
//        }];
        UIView *containerView = [[UIView alloc] init];
        [self addSubview:containerView];
        [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
//            make.left.right.equalTo(self);
        }];
        _contentView  = [[UIView alloc] init];
        _contentView.backgroundColor = LYRGBColor(25, 43, 60);
        _contentView.layer.cornerRadius = 16;
        _contentView.layer.masksToBounds = true;
        [containerView addSubview:_contentView];
        [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(containerView.mas_top).offset(450);
            make.left.equalTo(containerView).offset(18);
            make.right.equalTo(containerView.mas_right).offset(-18);
            make.bottom.equalTo(containerView).offset(20);
        }];
        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.font = [LYFont fontWithSize:22 fontName:LYFontNamepfb];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.text = @"AquaPolo";
        [_contentView addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_contentView.mas_top).offset(24);
            make.left.right.equalTo(_contentView);
        }];
        
        UILabel *subTitleLabel = [[UILabel alloc] init];
        subTitleLabel.textColor = LYRGBAColor(255, 255, 255, 0.5);
        subTitleLabel.font = [LYFont fontWithSize:16 fontName:LYFontNamepfr];
        subTitleLabel.textAlignment = NSTextAlignmentCenter;
        subTitleLabel.text = @"A home for water polo fanatics!";
        [_contentView addSubview:subTitleLabel];
        [subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(titleLabel.mas_bottom).offset(16);
            make.left.right.equalTo(_contentView);
        }];
        
        _appleLoginButton = [[APLoginButton alloc] init];
        _appleLoginButton.layer.cornerRadius = 27;
        _appleLoginButton.backgroundColor = LYRGBColor(51, 51, 51);
        _appleLoginButton.iconImageView.image = [UIImage imageNamed:@"apple- logo"];
        _appleLoginButton.titleLabel.text = @"Sign in with Apple";
        _appleLoginButton.titleLabel.textColor = UIColor.whiteColor;
        [_contentView addSubview:_appleLoginButton];
        [_appleLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(subTitleLabel.mas_bottom).offset(25);
            make.left.equalTo(_contentView.mas_left).offset(38);
            make.right.equalTo(_contentView.mas_right).offset(-38);
            make.height.mas_equalTo(54);
        }];
        
        _fastLoginButton = [[APLoginButton alloc] init];
        _fastLoginButton.layer.cornerRadius = 27;
        _fastLoginButton.backgroundColor = UIColor.whiteColor;
        _fastLoginButton.iconImageView.image = [UIImage imageNamed:@"fast_login_icon"];
        _fastLoginButton.titleLabel.text = @"Fast Login";
        _fastLoginButton.titleLabel.textColor = LYRGBColor(32, 32, 32);
        [_contentView addSubview:_fastLoginButton];
        [_fastLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_appleLoginButton.mas_bottom).offset(32);
            make.left.equalTo(_contentView.mas_left).offset(38);
            make.right.equalTo(_contentView.mas_right).offset(-38);
            make.height.mas_equalTo(54);
        }];
        
        _protocolControl = [[APProtocolControl alloc] init];
        [_contentView addSubview:_protocolControl];
        [_protocolControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_fastLoginButton.mas_bottom).offset(38);
            make.left.right.equalTo(_contentView);
            make.bottom.equalTo(_contentView.mas_bottom).offset(-64);
            make.height.mas_equalTo(40);
        }];
        
        
    }
    return self;
}
@end
